package com.gzx.spring.db.controller;

import java.util.List;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gzx.risk.core.pojo.CommonResult;
import com.gzx.risk.core.tags.CommonLog;
import com.gzx.spring.db.param.AddParam;
import com.gzx.spring.db.param.IdParam;
import com.gzx.spring.db.service.SimpleService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;

@Tag(name = "simple控制器")
@RestController
@Validated
@RequestMapping("/api/simple")
public class SimpleController {
	@Resource
	private SimpleService simpleService;
    @Operation(summary = "添加")
    @CommonLog("添加")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid AddParam param) {
    	simpleService.add(param);
        return CommonResult.ok();
    }

    @Operation(summary = "删除")
    @CommonLog("删除")
    @PostMapping("/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<IdParam> paramList) {
    	simpleService.delete(paramList);
        return CommonResult.ok();
    }
}
